import {Component, OnInit, ViewEncapsulation} from '@angular/core';
import {NavigationEnd, Router} from "@angular/router";
import {Location} from "@angular/common";
@Component({
    selector: '[appMenu]',
    templateUrl: './menu.component.html',
    styleUrls: ['./menu.component.css']
})
export class MenuComponent implements OnInit {
    public isCollapsed = true;
    public currentRouter: string;
    public menuArr: any = [
        {
            icon: 'anticon anticon-message',
            routerLink: '/home/chat',
        },
        {
            icon: 'anticon anticon-team',
            routerLink: '/home/contacts',
        },
        {
            icon: 'anticon anticon-star-o',
            routerLink: '/home/star',
        },
        {
            icon: 'anticon anticon-file',
            routerLink: '/home/file',
        }

    ];

    constructor(public router: Router, public location: Location) {
        this.currentRouter = this.location.path();
        console.log(`this.currentRouter ------> `, this.currentRouter)
    }

    ngOnInit() {
        this.router.events.subscribe(res => {
            if (res instanceof NavigationEnd) {
                this.currentRouter = this.location.path();
                console.log(`this.currentRouter ------> `, this.currentRouter)
            }
        })
    }
}
